/* 
 * File:   Dictionary.h
 * Author: eduardo
 *
 * Created on 5 de noviembre de 2012, 20:45
 */
#include "Dictionary.h"

Dictionary::Dictionary() {
}

Dictionary::~Dictionary() {
    _dict.clear();
}

int Dictionary::getSize() {
    return _dict.size();
}

void Dictionary::clear() {
    _dict.clear();
}

int Dictionary::insertTerm(string entry, int post) {
    int ret = 0;
    if (!belongTo(entry)) {
        _dict[entry] = post;
        ret = 1;
    }
    return ret;
}

int Dictionary::getValue(const string& key) {
    return _dict.at(key);
}

inline bool Dictionary::belongTo(const string& key) {
    return _dict.find(key) != _dict.end();
}